#include "cli.h"

int readCLI(int argc, char *argv[], string& in, string& out){
    int i;
    int state = 0;

    string parHelp("-h");
    string parInput("-i");
    string parOut("-o");
    string parVerbose("-v");

    for(i = 0; i < argc; i++){
        //check for "-v"
        if(!parVerbose.compare(argv[i])){
            state++;
            DEBUG++;
            cout << "verbose mode ON" << endl;
        }
        //check for "-h"
        else if(!parHelp.compare(argv[i])){
            cout << "SYNTAX: sort2 -i FILENAME -o FILENAME -v -h" << endl;
            cout << "\t-i FILENAME\t- input file to be sorted" << endl;
            cout << "\t-o FILENAME\t- the output file (comma seperated)" << endl;
            cout << "\t-v\t\t- verbose mode" << endl;
            cout << "\t-h\t\t- help page (the one you're looking at right now)" << endl;
            //abort app after printing help screen
            return(0);
        }
        //check for "-i"
        else if(!parInput.compare(argv[i])){
            if(argv[i+1]){
                in.assign(argv[i+1]);
                if(DEBUG>1){cout << "\nFILE(IN):\t" << argv[i+1] << endl;}
            }
            else{cout << "empty input parameter" << endl;}



            state++;
        }
        //check for "-o"
        else if(!parOut.compare(argv[i])){
            if(argv[i+1]){
                out.assign(argv[i+1]);
                if(DEBUG>1){cout << "\nFILE(OUT):\t" << argv[i+1] << endl;}
            }
            else{cout << "empty output parameter" << endl;}

            state++;
        }
    }
    return(state);
}

